/**
 * @author Linrui
 * @since 2011-05-01
 * 判断用户类型的拦截器
 */
package com.qeado.util.interceptors;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.qeado.user.model.User;
@Component
public class CompanyUserInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		User user = (User)ActionContext.getContext().getSession().get("login_user");
		/* 比较用户request中传入的类型值，若和session中的匹配，则可进行访问 */
		if( "0".equals(user.getCategory()) ) {
			return invocation.invoke();
		} else {
			return "fail";
		}
	}

}
